package abacab.remote.protocol;

import java.io.IOException;
import java.net.ConnectException;

import abacab.remote.Connection;
import abacab.remote.ConnectionRegistry;

/**
 * A factory to build the implementation to use for remoting
 */
public interface ImplementationFactory {
	/**
	 * Build the acceptor
	 * 
	 * @param registry
	 *          the registry
	 * @return the acceptor implementation
	 * @throws IOException
	 *           if unable to listen
	 */
	Acceptor buildAcceptor(ConnectionRegistry registry) throws IOException;

	/**
	 * Build a client connection to a remote acceptor
	 * 
	 * @param connectionRegistry
	 *          the registry
	 * @param hostname
	 *          the remote hostname
	 * @param port
	 *          the remote port
	 * @return the connection
	 * @throws ConnectException
	 *           if the connection failed to be established
	 */
	Connection buildClient(ConnectionRegistry connectionRegistry, String hostname, int port) throws ConnectException;
}